package v1beta1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type VPCStatusType string

const (
	VPCStatusCreating VPCStatusType = "Creating"
	VPCStatusReady    VPCStatusType = "Ready"
)

// VpcSpec defines the desired state of vpc
type VpcSpec struct {
	//+optional
	OwnerId string `json:"ownerId,omitempty"`
	//Just sync VPC and Subnet information and doesn' create if VPCID is not nil.
	VPCID       string      `json:"vpcid,omitempty"`
	CIDR        string      `json:"cidr,omitempty"`
	Subnet      Subnet      `json:"subnet,omitempty"`
	ProviderRef ProviderRef `json:"providerRef,omitempty"`
}

type Subnet struct {
	//+optional
	//+kubebuilder:default:=true
	AutoCreated bool   `json:"autoCreate,omitempty"`
	Name        string `json:"name,omitempty"`
	CIDR        string `json:"cidr,omitempty"`
	GatewayIp   string `json:"gatewayIp,omitempty"`
}

type VPCStatus struct {
	SubNetId string        `json:"subnetId"`
	VPCId    string        `json:"vpcId"`
	Phase    VPCStatusType `json:"phase"`
	//+optional
	NatGatewayIds []string `json:"natGatewayIds"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName=vpc
// +kubebuilder:subresource:status

// Vpc is the Schema for the vpc API
type Vpc struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec VpcSpec `json:"spec,omitempty"`
	//+kubebuilder:pruning:PreserveUnknownFields
	// +optional
	// +nullable
	Status VPCStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// VpcList contains a list of vpc item
type VpcList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Vpc `json:"items"`
}
